<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<%
    pageContext.setAttribute("APP_PATH", request.getContextPath());

%>
<head>

    <title>员工列表</title>
    <script src="${APP_PATH}/static/js/jquery.min.js" type="text/javascript"></script>
    <link href="${APP_PATH}/static/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <script src="${APP_PATH}/static/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
</head>
<body>

<%--搭建显示页面--%>
<div class="jumbotron text-center" style="margin-bottom:0">
    <h1>员工信息管理表</h1>
</div>
<div class="container">
    <%--删除按钮--%>
    <div class="row">
        <div class="col-lg-4 col-md-offset-8">
            <button class="btn btn-primary">新增</button>
            <button class="btn btn-danger">删除</button>
        </div>
    </div>
    <%--表格数据--%>
    <div class="row">
        <div class="col-lg-12">
            <table class="table table-striped">
                <caption>基本的表格布局</caption>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>Lastname</th>
                    <th>email</th>
                    <th>gender</th>
                    <th>deptName</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>

                <c:forEach items="${pageInfo.list}" var="emp">
                    <tr>
                        <td>${emp.empId}</td>
                        <td>${emp.empName}</td>
                        <td>${emp.email}</td>
                        <td>${emp.gender=="M"?"男":"女"}</td>
                        <td>${emp.department.deptName}</td>
                        <td>
                            <button class="btn btn-primary btn-sm">
                        <span class="glyphicon glyphicon-pencil">
                            编辑
                        </span>
                            </button>
                            <button class="btn btn-danger btn-sm">
                        <span class="glyphicon glyphicon-remove">
                            删除
                        </span>
                            </button>
                        </td>

                    </tr>
                </c:forEach>

                </tbody>
            </table>
        </div>
    </div>
    <%--分页--%>
    <div class="row">
        <div class="col-md-6">
            当前第${pageInfo.pageNum}页 总${pageInfo.pages}页 共${pageInfo.total}条录数
        </div>
        <div class="col-md-6">
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <c:if test="${pageInfo.isFirstPage}">
                        <li class="disabled"><a href="#">首页</a></li>
                    </c:if>

                    <c:if test="${!pageInfo.isFirstPage}">
                        <li><a href="${APP_PATH}/emps">首页</a></li>
                    </c:if>
                    <c:if test="${pageInfo.hasPreviousPage}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=${pageInfo.prePage}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${!pageInfo.hasPreviousPage}">
                        <li class="disabled">
                            <a href="#" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <c:forEach items="${pageInfo.navigatepageNums}" var="num">
                        <c:if test="${pageInfo.pageNum==num}">
                            <li class="active"><a href="#">${num}</a></li>
                        </c:if>
                        <c:if test="${pageInfo.pageNum!=num}">
                            <li><a href="${APP_PATH}/emps?pn=${num}">${num}</a></li>
                        </c:if>

                    </c:forEach>
                    <c:if test="${!pageInfo.hasNextPage}">
                        <li class="disabled">
                            <a href="#" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <c:if test="${pageInfo.hasNextPage}">
                        <li>
                            <a href="${APP_PATH}/emps?pn=${pageInfo.nextPage}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>

                    <c:if test="${pageInfo.isLastPage}">
                        <li class="disabled"><a href="#">末页</a></li>
                    </c:if>
                    <c:if test="${!pageInfo.isLastPage}">
                        <li><a href="${APP_PATH}/emps?pn=${pageInfo.pages}">末页</a></li>
                    </c:if>
                </ul>
            </nav>
        </div>

    </div>
</div>
</body>
</html>
